package com.flw.eslab.service.impl;

import java.io.File;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.flw.eslab.dao.TaskDao;
import com.flw.eslab.dto.PageInfo_Dto;
import com.flw.eslab.model.Task;
import com.flw.eslab.service.TaskManager;



//@Service("taskManager")
public class TaskManagerImpl implements TaskManager {
    private TaskDao taskDao;
	@Resource
	public void setTaskDao(TaskDao taskDao)
	{
		this.taskDao=taskDao;
	}
	public TaskDao getTaskDao() {
		return taskDao;
	}
	
	
	
	@Override
	public boolean add(Task task) {
		// TODO Auto-generated method stub
		if(task.getContend()==null||task.getContend().equals(""))
			return false;
		else
			taskDao.save(task);
		return true;
	}
	@Override
	public boolean delect(Task task) {
		if(task.getId()==null)
			return false;
		else{
			if(taskDao.findById(Task.class, task.getId())==null)
				return false;
			else{
				taskDao.deleteById(Task.class, task.getId());
				return true;
			}
		}
	}
	@Override
	public boolean modify(Task task) {
		if(task.getId()==null||task.getContend()==null||task.getContend().equals(""))
			return false;
		else{
			if(taskDao.findById(Task.class, task.getId())==null)
				return false;
			else{
				taskDao.update(task);
				return true;
			}
		}
	}
	@Override
	public File output() {
		// TODO Auto-generated method stub
		return null;
	}
	@Override
	public PageInfo_Dto load(PageInfo_Dto pageInfo_Dto) {
		int pageNow=pageInfo_Dto.getPageNow()==null?1:pageInfo_Dto.getPageNow();
		int pageSize=pageInfo_Dto.getPagesize()==null?5:pageInfo_Dto.getPagesize();	
		return taskDao.findByPageInfo(Task.class, pageNow, pageSize, null, null);
	}
	
	
	
}
